<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width"/>
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>选择模式</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../css/reset.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <style type="css/text">
      #footer{margin: 10px;}
      #footer p{margin-left:10px;margin-right:10px;}
    </style>
</head>
<body>
  <div id="wrap" class="flex-wrap flex-vertical">
      <header id="header" class="aui-bar aui-bar-nav">
        <a class="aui-pull-left" tapmode="hover" onclick="api.closeWin();">
           <span class="aui-iconfont aui-icon-left"></span>
        </a>
         <div class="aui-title">选择模式</div>
         <a class="aui-pull-right" tapmode="hover" onclick="fnclear()">

         </a>
      </header>
       <div id="main" class="flex-con">

       </div>
  </div>

</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/aui-toast.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script trpe="text/javascript">
  var toast,codeData;
  apiready =function(){
     //$api.fixStatusBar($api.dom('header'));
    //$api.text($api.dom('#connectionType'),'网络环境:'+api.connectionType);

     toast=new auiToast({});
     calcNum();
     init();

     api.addEventListener({
         name: 'calcNumEvent'
     }, function(ret, err){
          calcNum();
     });

  };

 function init(){
   api.openFrame({
       name: 'state',
       url: '../html/state.html',
       bounces: true,
       rect: {
           x: 0,
           y: $api.dom('header').offsetHeight,
           w: api.winWidth,
           h: $api.dom('#main').offsetHeight
       }
    });
 };


 function calcNum(){
   codeData =$api.getStorage(codeDataKey);
   let count =$api.dom('#count');
   if(!codeData){
     $api.text(count,'同步数据');
   }else{
     let num = codeData.length;
     if(num>0){
        $api.text(count,'同步数据('+num+')');
     }else{
        $api.text(count,'同步数据');
     }

   }

 };

 // clear come on!
 function fnclear(){
   $api.rmStorage(codeDataKey);
    toast.success({
       title:'清空完毕',
       duration:2000
    });

    api.sendEvent({
        name: 'clearEvent',
    });



 };

</script>
</html>
